<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2017/8/24
 * Time: 10:17
 */

namespace app\common\model;
use traits\model\SoftDelete;


class Tag extends BaseModel
{
    protected $table = 'ng_tags';
    protected $createTime = 'created_at';
    protected $updateTime = 'updated_at';
    protected $autoWriteTimestamp = 'datetime';

    use SoftDelete;
    protected $deleteTime = 'deleted_at';

    protected $hidden = [
        'created_at',
        'updated_at',
        'deleted_at'
    ];

    public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id');
    }

    public function checkTagName($name)
    {
         $result = $this->where(['name'=>$name])->find() ? true : false;
         return $result;
    }

}